<%= stylesheet_link_tag "components/_search_box" %>

<script type="text/javascript" charset="utf-8">
    $(function () {
        var searchBox = root.getWidgetById("search-box");

        searchBox.on("keydown", function (e) {
            e =e || window.event;
            var keyValue = e.which || e.keyCode;
            if (keyValue === 13) {
                Cookies.set('search_prev', "<%= request.path %>")
                window.location.href = e.target.con.dataset.href;
            }
        });

        <% if ENV['ON_PC'] %>
        // 点击跳转
        searchBox.on("click", function (e) {
            window.location.href = e.target.con.dataset.href;
        });
        <% end %>
    });
</script>

<div fe-role="Switch">
  <div data-href="<%= search_path %>" id="search-box" fe-role="Widget">
    <div class="magnifier">
      <%= image_tag "icons/white_search.png" %>
    </div>
    <div class="search-context">搜索</div>
  </div>
</div>
